import request from '@/utils/request'

/**
 * 创建支付订单
 */
export async function createPayment(orderNo: string, openid: string) {
  return request({
    url: '/payment',
    method: 'POST',
    data: {
      order_no: orderNo,
      openid
    }
  })
}

/**
 * 查询支付状态
 */
export async function queryPaymentStatus(orderNo: string) {
  return request({
    url: `/payment/${orderNo}`,
    method: 'GET'
  })
}

/**
 * 申请退款
 */
export async function refundPayment(orderNo: string, refundReason?: string) {
  return request({
    url: '/payment/refund',
    method: 'POST',
    data: {
      order_no: orderNo,
      refund_reason: refundReason
    }
  })
}
